package com.breaktian.demoapp.ui.refreshdemo;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.breaktian.assemble.refresh.superrefresh.PullRefreshLayout;
import com.breaktian.assemble.utils.ThreadUtil;
import com.breaktian.demoapp.R;

public class NestedScrollViewActivity extends AppCompatActivity {

    private LinearLayout linearlayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nested_scroll_view);

        final PullRefreshLayout pullRefreshLayout = (PullRefreshLayout)findViewById(R.id.pullRefreshLayout);
        pullRefreshLayout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
            @Override
            public void onPullDown() {
                ThreadUtil.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pullRefreshLayout.stopPullDownRefresh();
                    }
                },1500);

            }

            @Override
            public void onLoadMore() {
                ThreadUtil.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pullRefreshLayout.stopLoadMore();
                    }
                },1500);

            }
        });

        linearlayout = (LinearLayout)findViewById(R.id.linearlayout);

        for(int i=0;i<40;i++){
            TextView tv = new TextView(this);
            tv.setText("hello word "+i);
            tv.setTextSize(16);
            tv.setTextColor(Color.parseColor("#000000"));
            linearlayout.addView(tv);
        }


    }
}
